<template>
  <div>
    <el-upload
      :headers="headers" :show-file-list='false'
      :action="action" :on-success="upload">
      <el-button size="small" type="primary" v-if="!imageUrl">上传图片</el-button>
    </el-upload>
  </div>
</template>

<script>
  import {base} from "../../../util/requests";
  export default {
    data() {
      return {
        imageUrl: '',
        action: base+'/upload/imgUpload',
        headers: {
          'token': localStorage.getItem('token')
        }
      };
    },
    methods:{
      upload(response, file, fileList) {
        this.imageUrl = response.data.filePath;
        this.$emit('img', this.imageUrl);
      },
    },
    mounted() {}
  };
</script>


<style scoped>

</style>
